<!DOCTYPE html>
<html lang="zh">

<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width,initial-scale=1.0" />
  <link rel="icon" href="favicon.ico" />
  <title>Html - 实验室</title>
  <style>
    html,
    body {
      border: 0;
      padding: 0;
      margin: 0;
      height: 100%;
      overflow: hidden;
    }
  </style>
</head>

<body>
  <div>Html 实验室</div>
  ces2123

  
  Cookie <input type="text" id="cookie" value="JSESSIONID=9B2BDFAF9FC56A8EF0FE4382C113129F" /> <br>
  额外奖励 <input type="text" id="bs" value="2.5" style="width: 30px" />%
  <button onclick="cx()">查询</button><br>
  <div id="resText"></div>
  <iframe src="http://quanyi.hxjx360.com/" id="iframe"></iframe>
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
  setTimeout(function () {
    const iframe = document.getElementById("iframe");
    const iwindow = iframe.contentWindow;
    const idoc = iwindow.document;
    const idocHtml = idoc.documentElement;
    const idocHead = idoc.head;
    const idocBody = idoc.body;
    console.log(iframe);
    console.log(iwindow);
    console.log(idoc);
    console.log(idocHtml);
    console.log(idocHead);
    console.log(idocBody);
  }, 1000)

  // $('.van-tab')
  // $('#header', this.document).remove()






  function cx() {
    const num = Number($("#bs").val());
    $.ajax({
      type: "POST",
      url: "http://quanyi.hxjx360.com/api/uiweb/equities/list",
      headers: {
        Cookie: $("#cookie").val(),
        Origin: '123',
        ff: '222'
      },
      crossDomain: true,
      contentType: "application/json",
      xhrFields: {
        withCredentials: true // 携带跨域cookie
      },
      data: {
        corporationIds: [],
        novice: false,
        page: 1,
        pageSize: 999,
        sortType: 1,
        sortValue: "deadLine",
        type: 1,
      },
      dataType: "json",
      success: function (data) {
        $("#resText").empty(); //清空resText里面的所有内容
        var html = "";
        let list = data.items.data;
        let fList = list.filter((item) => {
          return item.expectedEarnings / item.awardAmount <= num;
        });
        fList.forEach((element) => {
          console.log(
            `符合 ${num} 的机构`,
            element,
            element.corporationName,
            getDaysBetween(element.calDate, element.deadLine)
          );
        });
        $("#resText").html(html);
      },
    });
  }

  function getDaysBetween(dateString1, dateString2) {
    var startDate = Date.parse(dateString1);
    var endDate = Date.parse(dateString2);
    if (startDate > endDate) {
      return 0;
    }
    if (startDate == endDate) {
      return 1;
    }
    var days = (endDate - startDate) / (1 * 24 * 60 * 60 * 1000);
    return parseInt(days);
  }
</script>

</html>